import org.junit.Test;
import utilities.JdbcUtil;

import java.sql.*;

public class LinkMySQL {
    @Test
    public void linkMySQL() throws SQLException {
        //获取数据库连接
        Connection connection = JdbcUtil.getConnection();

        String sql = "SELECT * FROM products";

        assert connection != null;
        Statement statement = connection.createStatement();

        ResultSet resultSet = statement.executeQuery(sql);
        while (resultSet.next()) {
            System.out.println(resultSet.getString(3) + "\t");
        }
        //6.关闭jdbc连接
        statement.close();
        connection.close();
    }
}